<?php
class IndexController extends Zend_Controller_Action
{    
    public function indexAction()
    {
    	$form = $this->view->form = new LoginForm();
        if ($this->getRequest()->isPost() 
            && $form->isValid($this->getRequest()->getPost())) {
            $adapter = new Zend_Auth_Adapter_DbTable(
                Zend_Db_Table_Abstract::getDefaultAdapter(),
                'users',
                'email',
                'password',
                'SHA1(CONCAT(?, salt))'
            );
            $adapter->setIdentity($form->getValue('email'));
            $password = Users::SALT . $form->getValue('password');
            $adapter->setCredential($password);
            
            $result = Zend_Auth::getInstance()->authenticate($adapter);
            if (!$result->isValid()) {
                var_dump($result->getMessages());
            } else {
                die('OK');
            }
        }  
    }
}
